Skip to content

Use pre-commit as a linter the CI suite#518

Merged
codingjoe merged 2 commits intomasterfrom
pre-commit
Dec 19, 2025
Merged

Use pre-commit as a linter the CI suite#518
codingjoe merged 2 commits intomasterfrom
pre-commit

Conversation

@codingjoe
Copy link
Copy Markdown
Owner

  • Add pre-commit hooks
  • Apply pre-commit changes

Copilot AI review requested due to automatic review settings December 19, 2025 10:00
@codingjoe codingjoe self-assigned this Dec 19, 2025
@codingjoe codingjoe changed the title pre commit Use pre-commit as a linter the CI suite Dec 19, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds pre-commit hooks configuration to the repository and applies automated formatting/linting changes across multiple files. The changes replace manual linting with an automated pre-commit workflow.

  • Adds .pre-commit-config.yaml with hooks for code quality, formatting, and linting
  • Replaces the lint job in CI with a pre-commit job
  • Applies automated formatting to YAML files and documentation

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
.pre-commit-config.yaml Adds pre-commit configuration with multiple hooks for code quality, formatting, and Django-specific checks
.github/workflows/ci.yml Replaces the lint job with a pre-commit job that runs all configured hooks
pyproject.toml Removes the lint extras dependency as linting is now handled by pre-commit
README.md Applies formatting changes including whitespace cleanup and backtick consistency
.github/workflows/release.yml Applies YAML formatting (whitespace cleanup)
.github/dependabot.yml Applies YAML formatting (indentation fixes)
.readthedocs.yaml Applies YAML formatting (whitespace cleanup)
health_check/contrib/mail/__init__.py Removes empty line from file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/ci.yml
Comment on lines +12 to +13
outputs:
file-names: ${{ steps.diff.outputs.file-names }}
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'file-names' output is defined but never used in any subsequent job. Consider removing the outputs section and the corresponding diff step (lines 12-13, 18-19) if this output is not needed, to simplify the workflow.

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/ci.yml
Comment on lines +18 to +19
- run: echo "file-names=$(git diff --name-only ${{ github.event.pull_request.base.sha }} HEAD | grep '\.py$' | tr '\n' ' ' || true)" >> "$GITHUB_OUTPUT"
id: diff
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The git diff command is calculating file names but the output is never used anywhere in the workflow. Consider removing this step if the file-names output is not needed.

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/ci.yml
with:
path: ~/.cache/pre-commit/
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- run: SKIP=$(yq '.ci.skip' -o csv .pre-commit-config.yaml) uvx pre-commit run --all-files --show-diff-on-failure
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command "uvx run pre-commit" appears to have incorrect syntax. The correct usage should be either "uvx pre-commit run" or "uv run pre-commit run" depending on whether pre-commit is installed via uvx or uv. The "uvx run" syntax is not a valid uvx command.

Copilot uses AI. Check for mistakes.
Comment thread .pre-commit-config.yaml
hooks:
- id: pyupgrade
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.29.1
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The django-upgrade hook is using a tag format '1.29.1' without the 'v' prefix, which is inconsistent with the other hooks in this configuration file. The correct tag format should be 'v1.29.1' based on the django-upgrade repository's tagging convention.

Suggested change
rev: 1.29.1
rev: v1.29.1

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/ci.yml
- uses: actions/cache@v5
with:
path: ~/.cache/pre-commit/
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow uses 'yq' command to parse the pre-commit config file, but 'yq' is not installed in any of the preceding steps. This will cause the job to fail. Consider installing yq using a GitHub Action like 'mikefarah/yq@master' or using an alternative approach to skip hooks.

Suggested change
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install yq
run: |
YQ_VERSION=v4.44.3
wget -q "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" -O yq
chmod +x yq
sudo mv yq /usr/local/bin/yq

Copilot uses AI. Check for mistakes.
@codingjoe codingjoe merged commit 859e449 into master Dec 19, 2025
12 checks passed
@codingjoe codingjoe deleted the pre-commit branch December 19, 2025 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants